#include <iostream>
#include <algorithm>

#include <string>

using std::cout;
using std::endl;


int main()
{
	{
		using namespace std;
		string si = "123";
		int dec = std::stoi(si);
		int hex = std::stol(si, 0, 16);
		cout << "string: " << si << ", dec: " << dec << " , hex: " << hex << endl;

		string sd = std::to_string(124.5);
		cout << "string double: " << sd << endl;
	}
	cout << endl;

	{
		using namespace std;
		string str("test string");
		const char *pstr = str.c_str();
		cout << pstr << endl;
		
		char *it = &(*str.begin());

		if (it == pstr)
		{
			cout << "same" << endl;
		}
		else
		{
			cout << "not same" << endl;
		}

		fill_n(it, 4, 'a');
		cout << str << endl;


	}
	cout << endl;

	{
		using namespace std;
		string str(20, '\0');
		cout << "capacity: " << str.capacity() << endl;
		cout << "size: " << str.size() << endl;

		str[0] = 'a';
		cout << "capacity: " << str.capacity() << endl;
		cout << "size: " << str.size() << endl;
	
		str.shrink_to_fit();
		cout << "capacity: " << str.capacity() << endl;
		cout << "size: " << str.size() << endl;

		cout << str << endl;
		cout << "length: " << str.length() << endl;
	}
	cout << endl;

}







